import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core';
import { PublicService } from '../public.service';

@Component({
    selector: 'itmp-vms-err',
    templateUrl: './Vms-err.component.html',
    styleUrls: ['./Vms-err.component.css']
})
export class VmsErrComponent implements OnInit {
    @Input() visible = false;
    @Output() visibleChange = new EventEmitter<boolean>();
    @Input() data: {};
    displayData = [];
    constructor(private pub: PublicService) {}
    ngOnInit() {
        this.getData();
    }
    getData() {
        const arr = [];
        for (const i in this.data) {
            if (i === 'deviceId') {
                const tempDeviceId = { name: i, value: this.data[i] };
                arr.unshift(tempDeviceId);
            } else {
                arr.push({ name: i, value: this.data[i] }); // 属性
            }
            // arr.push(obj[i]); //值
        }

        this.displayData = arr;
    }
    close() {
        this.visible = false;
        this.visibleChange.emit(this.visible);
    }

    // 初始化数据
    initData() {}
    // cancel 按钮
    handleCancel() {
        this.close();
    }
}
